'use strict';

const { Controller } = require('egg');
class UserController extends Controller {
	async mpLogin() {
		const { code } = this.ctx.query;
		return await this.service.loginService.mpLogin(code);
	}
	async decryptPhone() {
		const { encryptedData, iv } = this.ctx.request.body;
		return await this.service.loginService.decryptPhone(encryptedData, iv);
	}
	async getCode() {
		const { mobile } = this.ctx.query;
		return await this.service.loginService.getCode(mobile);
	}
	async phoneLogin() {
		const { mobile, code } = this.ctx.query;
		return await this.service.loginService.phoneLogin(mobile, code);
	}
	async userInfo() {
		const LoginService = this.service.loginService;
		return await LoginService.getUserInfo();
	}
	async salesman() {
		return await this.service.channelUserService.getUserByMobile();
	}
	async dict() {
		const { key } = this.ctx.params;
		return await this.service.dictService.getDict(key);
	}
	async message() {
		return await this.ctx.service.messageService.index();
	}
	async unreadMessage() {
		return await this.ctx.service.messageService.unreadMessage()
	}
}

module.exports = UserController;